Backbone.View.extend.render   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 9.4285
1
import Backbone from 'backbone';
0 ignored issues
show
introduced by
Definition for rule 'keyword-spacing' was not found
Loading history...
2
import _ from 'underscore';
3
import {
4
  Backgrid
5
} from './core.js';
6
/**
7
   EmptyRow is a simple container view that takes a list of column and render a
8
   row with a single column.
9
10
   @class Backgrid.EmptyRow
11
   @extends Backbone.View
12
*/
13
var EmptyRow = Backbone.View.extend({
14
15
  /** @property */
16
  tagName: "tr",
17
18
  /** @property {string|function(): string} */
19
  emptyText: null,
20
21
  /**
22
     Initializer.
23
24
     @param {Object} options
25
     @param {string|function(): string} options.emptyText
26
     @param {Backbone.Collection.<Backgrid.Column>|Array.<Backgrid.Column>|Array.<Object>} options.columns Column metadata.
27
   */
28
  initialize: function (options) {
29
    this.emptyText = options.emptyText;
30
    this.columns = options.columns;
31
  },
32
33
  /**
34
     Renders an empty row.
35
  */
36
  render: function () {
37
    this.$el.empty();
38
39
    var td = document.createElement("td");
40
    td.setAttribute("colspan", this.columns.length);
41
    var span = document.createElement("span");
42
    span.innerHTML = _.result(this, "emptyText");
43
    td.appendChild(span);
44
45
    this.el.className = "empty";
46
    this.el.appendChild(td);
47
48
    return this;
49
  }
50
});
51
export {
52
  EmptyRow
53
};
54